home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _EE60214C26C54A4C9652E42368F87CEA < prev    next >
Encoding:
Text File  |  2004-01-06  |  11.0 KB  |  326 lines

  1. --------------------------------------------------
  2. --   Created By: petar
  3. --   Description: the idle behaviour for the guard
  4. --------------------------
  5. --   modified by: sten 23-10-2002
  6.  
  7. AIBehaviour.CoverGuardIdle = {
  8.     Name = "CoverGuardIdle",
  9.     
  10.  
  11.  
  12.     OnPlayerSeen = function( self, entity, fDistance )
  13.         -- called when the enemy sees a living player
  14.         -- REVIEWED
  15.         if (AI:GetGroupCount(entity.id) > 1) then    
  16.             AI:Signal(SIGNALID_READIBILITY, AIREADIBILITY_SEEN, "FIRST_HOSTILE_CONTACT_GROUP",entity.id);    
  17.         else
  18.             AI:Signal(SIGNALID_READIBILITY, AIREADIBILITY_SEEN, "FIRST_HOSTILE_CONTACT",entity.id);    
  19.         end
  20.         
  21.         
  22.         if (AI:GetGroupCount(entity.id) > 1) then
  23.             -- only send this signal if you are not alone
  24.             entity:SelectPipe(0,"cover_scramble_beacon");
  25.  
  26.             if (entity:NotifyGroup()==nil) then
  27.                 AI:Signal(SIGNALFILTER_SUPERGROUP, 1, "HEADS_UP_GUYS",entity.id);
  28.                 AI:Signal(SIGNALFILTER_SUPERGROUP, 1, "wakeup",entity.id);
  29.             end
  30.  
  31.         else
  32.             -- you are on your own
  33.             entity:SelectPipe(0,"cover_pindown");
  34.         end
  35.  
  36.  
  37. --        if (entity.RunToTrigger == nil) then
  38. --            entity:RunToAlarm();
  39. --        end
  40.  
  41.         
  42.  
  43.     end,
  44.     ---------------------------------------------
  45.     OnSomethingSeen = function( self, entity )
  46.         -- called when the enemy sees a foe which is not a living player
  47.  
  48.         -- DO NOT TOUCH THIS READIBILITY SIGNAL    ---------------------------
  49.         if (AI:GetGroupCount(entity.id) > 1) then
  50.             AI:Signal(SIGNALID_READIBILITY, AIREADIBILITY_INTERESTING, "IDLE_TO_INTERESTED_GROUP",entity.id);
  51.         else
  52.             AI:Signal(SIGNALID_READIBILITY, AIREADIBILITY_INTERESTING, "IDLE_TO_INTERESTED",entity.id);
  53.         end
  54.         -------------------------------------------------------------------
  55.  
  56.         entity:SelectPipe(0,"cover_look_closer");
  57.         entity:InsertSubpipe(0,"setup_stealth"); 
  58.         entity:InsertSubpipe(0,"DRAW_GUN"); 
  59.  
  60.         -- you are going to CoverInterested
  61.     end,
  62.     ---------------------------------------------
  63.     OnEnemySeen = function( self, entity )
  64.         -- called when the enemy sees a foe which is not a living player
  65.     end,
  66.     ---------------------------------------------
  67.     OnEnemyMemory = function( self, entity )
  68.         -- called when the enemy can no longer see its foe, but remembers where it saw it last
  69.     end,
  70.     ---------------------------------------------
  71.     OnInterestingSoundHeard = function( self, entity )
  72.         -- DO NOT TOUCH THIS READIBILITY SIGNAL    ---------------------------
  73.         if (AI:GetGroupCount(entity.id) > 1) then
  74.             AI:Signal(SIGNALID_READIBILITY, AIREADIBILITY_NORMAL, "IDLE_TO_INTERESTED_GROUP",entity.id);
  75.         else
  76.             AI:Signal(SIGNALID_READIBILITY, AIREADIBILITY_NORMAL, "IDLE_TO_INTERESTED",entity.id);
  77.         end
  78.         -------------------------------------------------------------------
  79.  
  80.  
  81.         entity:SelectPipe(0,"cover_look_closer");
  82.         entity:InsertSubpipe(0,"setup_stealth"); 
  83.         entity:InsertSubpipe(0,"DRAW_GUN"); 
  84.     
  85.     end,
  86.     ---------------------------------------------
  87.     OnThreateningSoundHeard = function( self, entity, fDistance )
  88.         -- called when the enemy hears a scary sound
  89.  
  90.  
  91.  
  92.         -- DO NOT TOUCH THIS READIBILITY SIGNAL    ---------------------------
  93.         AI:Signal(SIGNALID_READIBILITY, AIREADIBILITY_NORMAL, "IDLE_TO_THREATENED",entity.id);
  94.         -------------------------------------------------------------------
  95.  
  96.         local dist = AI:GetAnchor(entity.id,AIAnchor.HOLD_THIS_POSITION,40);
  97.         local d = tonumber(dist);
  98.  
  99.         if (d) then
  100.         if (fDistance>d) then
  101.             entity:MakeAlerted();
  102.  
  103.             AI:Signal(0,1,"HOLD_POSITION",entity.id);
  104.             entity:SelectPipe(0,"special_hold_position");
  105.             if (entity.AI_GunOut) then
  106.                 entity:InsertSubpipe(0,"setup_stealth"); 
  107.                 entity:InsertSubpipe(0,"DRAW_GUN"); 
  108.             end
  109.         else
  110.             entity:MakeAlerted();
  111.  
  112.             AI:Signal(0,1,"NORMAL_THREAT_SOUND",entity.id);
  113.  
  114.             entity:SelectPipe(0,"cover_investigate_threat"); 
  115.             if (fDistance > 20) then 
  116.                 entity:InsertSubpipe(0,"do_it_running");
  117.             else
  118.                 entity:InsertSubpipe(0,"do_it_walking");
  119.             end
  120.  
  121.             entity:InsertSubpipe(0,"cover_threatened"); 
  122.         end
  123.         else    
  124.             entity:MakeAlerted();
  125.  
  126.             AI:Signal(0,1,"NORMAL_THREAT_SOUND",entity.id);
  127.  
  128.             entity:SelectPipe(0,"cover_investigate_threat"); 
  129.             if (fDistance > 20) then 
  130.                 entity:InsertSubpipe(0,"do_it_running");
  131.             else
  132.                 entity:InsertSubpipe(0,"do_it_walking");
  133.             end
  134.  
  135.             entity:InsertSubpipe(0,"cover_threatened"); 
  136.         end
  137.  
  138.     end,
  139.     --------------------------------------------------
  140.     OnCoverRequested = function ( self, entity, sender)
  141.         -- called when the enemy is damaged
  142.     end,
  143.     ---------------------------------------------
  144.     OnReceivingDamage = function ( self, entity, sender)
  145.         -- called when the enemy is damaged
  146.         AI:Signal(SIGNALFILTER_GROUPONLY, 1, "INCOMING_FIRE",entity.id);
  147.  
  148.         -- DO NOT TOUCH THIS READIBILITY SIGNAL    ------------------------
  149.         AI:Signal(SIGNALID_READIBILITY, 1, "GETTING_SHOT_AT",entity.id);
  150.         ----------------------------------------------------------------
  151.  
  152.         entity:MakeAlerted();
  153.         entity:SelectPipe(0,"randomhide");
  154.         entity:InsertSubpipe(0,"DRAW_GUN");
  155.     end,
  156.     ---------------------------------------------
  157.     OnReload = function( self, entity )
  158.         -- called when the enemy goes into automatic reload after its clip is empty
  159.         entity:SelectPipe(0,"cover_scramble");
  160.     end,
  161.     --------------------------------------------------
  162.     OnBulletRain = function ( self, entity, sender)
  163.         -- called when detect weapon fire around AI
  164.     
  165.         AI:Signal(SIGNALFILTER_GROUPONLY, 1, "INCOMING_FIRE",entity.id);
  166.         
  167.         entity:MakeAlerted();
  168.         entity:SelectPipe(0,"randomhide");
  169.         entity:InsertSubpipe(0,"DRAW_GUN");
  170.     end,
  171.     --------------------------------------------------
  172.     OnGrenadeSeen = function( self, entity, fDistance )
  173.         -- called when the enemy sees a grenade
  174.         
  175.         -- DO NOT TOUCH THIS READIBILITY SIGNAL    ---------------------------
  176.         AI:Signal(SIGNALID_READIBILITY, 1, "GRENADE_SEEN",entity.id);
  177.         -------------------------------------------------------------------
  178.         entity:InsertSubpipe(0,"cover_grenade_run_away");
  179.  
  180.     end,
  181.     --------------------------------------------------
  182.     -- CUSTOM SIGNALS
  183.     --------------------------------------------------
  184.  
  185.     --------------------------------------------------
  186.     OnGroupMemberDied = function( self, entity, sender)
  187.                 
  188. --        if (entity.RunToTrigger == nil) then
  189. --            local runAlarm = self:RUN_TO_TRIGGER(entity);
  190. --        end
  191.         
  192.         -- call the default to do stuff that everyone should do    
  193. --        if (runAlarm == nil) then
  194.             AIBehaviour.DEFAULT:OnGroupMemberDied(entity,sender);
  195.         
  196.             -- do cover stuff
  197.             if (sender.groupid == entity.groupid) then
  198.                  if (entity ~= sender) then
  199.                      entity:SelectPipe(0,"TeamMemberDiedLook");
  200.                  end
  201.             else
  202.                  entity:SelectPipe(0,"randomhide");
  203.             end
  204. --        end
  205.     end,
  206.     --------------------------------------------------
  207.     OnGroupMemberDiedNearest = function ( self, entity, sender)
  208.         -- call the default to do stuff that everyone should do
  209. --        if (entity.RunToTrigger == nil) then
  210. --            local runAlarm = self:RUN_TO_TRIGGER(entity);
  211. --        end
  212.         
  213. --        if (runAlarm == nil) then
  214.             AIBehaviour.DEFAULT:OnGroupMemberDiedNearest(entity,sender);
  215.  
  216.             -- do cover stuff here
  217.             -- investigate corpse
  218.             entity:SelectPipe(0,"RecogCorpse",sender.id);
  219. --        end
  220.     end,
  221.     --------------------------------------------------
  222.     COVER_NORMALATTACK = function (self, entity, sender)
  223.         entity:SelectPipe(0,"cover_pindown");
  224.     end,
  225.     --------------------------------------------------
  226.     COVER_RELAX = function (self, entity, sender)
  227.         entity:SelectPipe(0,"standingthere");
  228.     end,
  229.     --------------------------------------------------
  230.     AISF_GoOn = function (self, entity, sender)
  231.         entity:SelectPipe(0,"standingthere");
  232.     end,
  233.     --------------------------------------------------
  234.  
  235.     ---------------------------------------------    
  236.     ALARM_ON = function (self, entity, sender)
  237.         -- the team can split
  238.         entity:SelectPipe(0,"investigate_alarm");        
  239.         entity:InsertSubpipe(0,"run_to_beacon");        
  240.         entity:InsertSubpipe(0,"DropBeaconAt",sender.id);        
  241.     end,
  242.  
  243.     INVESTIGATE_TARGET = function (self, entity, sender)
  244.         entity:SelectPipe(0,"cover_investigate_threat");        
  245.     end,
  246.     ---------------------------------------------
  247.     -- GROUP SIGNALS
  248.     --------------------------------------------------
  249.     HEADS_UP_GUYS = function (self, entity, sender)
  250.         if (entity ~= sender) then
  251.             entity:MakeAlerted();
  252.             entity:SelectPipe(0,"cover_beacon_pindown");
  253.             entity:InsertSubpipe(0,"DRAW_GUN");
  254.         end
  255.         entity.RunToTrigger = 1;
  256.     end,
  257.     ---------------------------------------------
  258.     INCOMING_FIRE = function (self, entity, sender)
  259.         if (entity ~= sender) then
  260.             entity:ChangeAIParameter(AIPARAM_SIGHTRANGE,entity.PropertiesInstance.sightrange*1.5);
  261.             entity:SelectPipe(0,"randomhide");
  262.             entity:InsertSubpipe(0,"DRAW_GUN");
  263.         end
  264.     end,
  265.     ---------------------------------------------
  266.     KEEP_FORMATION = function (self, entity, sender)
  267.  
  268.         entity:SelectPipe(0,"cover_hideform");
  269.         entity:InsertSubpipe(0,"acquire_beacon");
  270.         if (entity.AI_GunOut == nil) then 
  271.             entity:InsertSubpipe(0,"DRAW_GUN");
  272.         end
  273.     end,
  274.     ---------------------------------------------    
  275.     MOVE_IN_FORMATION = function (self, entity, sender)
  276.         -- the team leader wants everyone to move in formation
  277.         -- DO NOT TOUCH THIS READIBILITY SIGNAL    ---------------------------
  278.         AI:Signal(SIGNALID_READIBILITY, 1, "ORDER_RECEIVED",entity.id);
  279.         -------------------------------------------------------------------
  280.  
  281.  
  282.         entity:SelectPipe(0,"MoveFormation");
  283.     end,
  284.     ---------------------------------------------    
  285.     BREAK_FORMATION = function (self, entity, sender)
  286.         -- the team can split
  287.     end,
  288.     ---------------------------------------------    
  289.     SINGLE_GO = function (self, entity, sender)
  290.         -- the team leader has instructed this group member to approach the enemy
  291.     end,
  292.     ---------------------------------------------    
  293.     GROUP_COVER = function (self, entity, sender)
  294.         -- the team leader has instructed this group member to cover his friends
  295.     end,
  296.     ---------------------------------------------    
  297.     IN_POSITION = function (self, entity, sender)
  298.         -- some member of the group is safely in position
  299.     end,
  300.     
  301.     ---------------------------------------------    
  302.     PHASE_RED_ATTACK = function (self, entity, sender)
  303.         -- team leader instructs red team to attack
  304.     end,
  305.     ---------------------------------------------    
  306.     PHASE_BLACK_ATTACK = function (self, entity, sender)
  307.         -- team leader instructs black team to attack
  308.     end,
  309.     ---------------------------------------------    
  310.     GROUP_MERGE = function (self, entity, sender)
  311.         -- team leader instructs groups to merge into a team again
  312.     end,
  313.     ---------------------------------------------    
  314.     CLOSE_IN_PHASE = function (self, entity, sender)
  315.         -- team leader instructs groups to initiate part one of assault fire maneuver
  316.     end,
  317.     ---------------------------------------------    
  318.     ASSAULT_PHASE = function (self, entity, sender)
  319.         -- team leader instructs groups to initiate part one of assault fire maneuver
  320.     end,
  321.     ---------------------------------------------    
  322.     GROUP_NEUTRALISED = function (self, entity, sender)
  323.         -- team leader instructs groups to initiate part one of assault fire maneuver
  324.     end,
  325.     
  326. }